<template>
	<view class="content">
		<view class="prize">
			<view class="lt">
				<img :src="prizeinner.prizesImage" alt="">
			</view>
			<view class="rt">
				<view>奖品名称：<text>{{prizeinner.prizesName}}</text></view>
				<view>奖品数量：<text>{{prizeinner.prizesSum}}</text></view>
				<view>发布时间：<text>{{prizeinner.createTime}}</text></view>
			</view>
		</view>
		<view class="tit_2" v-if="addpeople!=0">已参与人数：{{addpeople}} 人</view>
		<view class="tit_2" v-else>暂时还没有人参与抽奖</view>
		<view class="prizer">
			<view class="tit">中奖名单：</view>
			<view class="prizerlist_1" v-if="prizerlist.length==0">
				暂时还没有人中奖哦
			</view>
			<view class="prizerlist_2" v-else>
				<view class="items" v-for="(item,index) in prizerlist" :key="index">
					<view class="icon">
						<img :src="item.avater" alt="">
					</view>
					<view class="detial">
						<view>中奖人：{{item.name}}</view>
						<view>中间时间：{{item.updateTime}}</view>
					</view>
				</view>
			</view>
		</view>
		<button @click="gocreate">再发布一个抽奖吧</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				prizeinner: {},
				prizerlist: [],
				addpeople: 0,
			}
		},
		onLoad(options) {
			console.log(options.prize_id);
			this.api_get(options.prize_id)
			console.log(this.prizerlist, '中奖用户数据');
		},
		methods: {
			api_get(id) {
				this.$api.request({
					url: this.$api.getprizeDetial + `/${id}`
				}).then((res) => {
					if (res.code == 200) {
						console.log(res.data);
						this.prizeinner = res.data.apiHtPrizes
						this.prizerlist = res.data.user
						this.addpeople = res.data.involvedNum
					}
				})
			},
			gocreate() {
				uni.navigateTo({
					url: '/myPage/prize_com/create'
				})
			},
		}
	}
</script>

<style scoped>
	.content {
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;
		background-color: #eee;
	}

	.prize {
		display: flex;
		flex-direction: row;
		width: 700rpx;
		height: 250rpx;
		margin: 0 auto;
		margin-top: 20rpx;
		background: linear-gradient(to right, yellow, orange 50%, red);
		border-radius: 30rpx;
	}

	.lt {
		width: 200rpx;
		height: 200rpx;
		margin: 25rpx;
		border-radius: 20rpx;
		overflow: hidden;
	}

	.lt img {
		width: 100%;
		height: 100%;
	}

	.rt {
		width: 420rpx;
		height: 200rpx;
		margin-top: 25rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-around;
	}

	.rt view {
		height: 60rpx;
		line-height: 60rpx;
		padding-left: 20rpx;
		border-radius: 30rpx;
		font-weight: bold;
		/* background-color: #fff; */
	}

	.tit_2 {
		width: 500rpx;
		height: 40rpx;
		text-align: center;
		background-color: #fff;
		margin: 0 auto;
		margin-top: 30rpx;
		border-radius: 20rpx;
	}

	.prizer {
		width: 700rpx;
		margin: 30rpx auto;
	}

	.tit {
		width: 700rpx;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 40rpx;
		padding-left: 30rpx;
		border-radius: 30rpx;
		font-weight: bold;
		background-color: #fff;
		box-shadow: 5rpx 5rpx 10rpx rgba(0, 0, 0, 0.5);
	}

	.prizerlist_1 {
		width: 650rpx;
		height: 200rpx;
		margin: 0 auto;
		text-align: center;
		line-height: 200rpx;
		background-color: #fff;
		font-weight: bold;
		font-size: 30rpx;
		margin-top: 10rpx;
		border-radius: 0 0 40rpx 40rpx;
	}

	.items {
		width: 650rpx;
		height: 120rpx;
		margin: 20rpx auto;
		background-color: #fff;
		border-radius: 60rpx;
		display: flex;
		flex-direction: row;
	}

	.items .icon {
		width: 100rpx;
		height: 100rpx;
		background-color: #ccc;
		margin: 10rpx 10rpx;
		border-radius: 50rpx;
	}

	.icon img {
		width: 100%;
		height: 100%;
	}

	.items .detial {
		display: flex;
		padding-left: 20rpx;
		flex-direction: column;
		justify-content: space-around;
	}

	button {
		width: 500rpx;
		height: 80rpx;
		position: fixed;
		bottom: 40rpx;
		left: 125rpx;
		border-radius: 40rpx;
		font-size: 36rpx;
		line-height: 80rpx;
		color: #fff;
		background: linear-gradient(to right, orange, red);
	}
</style>